PERSISTENT MODEL DATA
Overview
Certain simulator models, particularly those for EPROMs and microcontrollers containing EEPROM or flash memory, are able to remember data between simulation runs, just like their real life counterparts. A program that writes a calibration constant to EEPROM on its first run can then read it back on the second, which is exactly what the real hardware would do.
This action is facilitated by the MODDATA property. Persistent model data blocks are stored in the design, and so do not persist between Proteus sessions unless you save the project.
The MODDATA Property
Models that support persistence carry the property already, so for most users this is something to read rather than to write. You will meet it if you are writing a model of your own, or if you want to preload a device with known contents. The syntax is:
MODDATA=size[,initval[,filename]]
where:
- size is the length of the block in bytes, and is the only mandatory field. It may be given in decimal, or in hexadecimal with a leading dollar sign.
- initval is the byte value the whole block is filled with before anything else happens. It defaults to zero, and is also accepted in the dollar sign hexadecimal form.
- filename names a file whose contents are read over the top of the initialised block. The same file may instead be named in a separate MODDATAFILE property, which is usually tidier and takes precedence where both are given.
The block belongs to the part that declares it, but a model built from several parts can share one block between them, which is how a processor model and its internal memory appear as one device.
The size must match what the model expects. Where it does not, the model reports the mismatch in the simulation log and falls back to non-persistent behaviour, for example:
Missing or incorrect MODDATA property - EEPROM will be non-persistent.
The size a given device needs is stated in the model specific help for that processor, which you can reach from the Edit Component dialogue form.
Where the Data Lives
The master copy of a persistent block is held in the design itself, which is why saving the project is what makes the contents survive. During a simulation, however, the working copy travels in the partition file for the partition the part belongs to. The simulator writes the block out there when the run ends and reads it back at the start of the next one, and while that is happening the MODDATA property is rewritten to record the partition, the offset and the size.
The practical consequence is that anything which invalidates a partition also discards the working copy of the data it carried, so a change that forces a re-simulation may reset a device you expected to hold its contents.
Resetting the Data
To reset the persistent model data to its initial condition, use the Reset Persistent Model Data command on the Debug menu. Every persistent block in the design is returned to the value its MODDATA property specifies, so a device with an initialiser goes back to that and a device without one goes back to zero.
See Also: